//Package controllers 包名可以和文件夹名不同，但是保持包名和文件夹名相同更利于被外部导入调用
package controllers

import (
	"fmt"

	"github.com/astaxie/beego"
)

// HelloController hello例子的控制器
type HelloController struct {
	beego.Controller
}

// Get hello控制器的get请求处理
func (helloCtl *HelloController) Get() {
	/*
		helloCtl.Ctx.WriteString("appname:" + beego.AppConfig.String("appname") +
			"\nhttpport:" + beego.AppConfig.String("httpport") +
			"\nrunmode:" + beego.AppConfig.String("runmode"))
	*/
	/*
		helloCtl.Ctx.WriteString("hello")
		beego.Trace("trace test1")
		beego.Info("info test1")
		beego.SetLevel(beego.LevelInformational)
		beego.Trace("trace test2") //trace级别比info低，所以信息不显示
		beego.Info("info test2")
	*/

	fmt.Println("----------------模版的使用---------------------")
	/*
	 */
	helloCtl.TplName = "hello.tpl" //指定模版文件
	helloCtl.Data["Website"] = "beego.me"
	helloCtl.Data["Email"] = "astaxie@gmail.com"
	helloCtl.Data["TrueCond"] = true
	helloCtl.Data["FalseCond"] = false

	type User struct {
		Name string
		Age  int
		Sex  string
	}

	u := &User{"jeo", 20, "Male"}
	helloCtl.Data["User"] = u
	nums := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
	helloCtl.Data["Nums"] = nums

	//模版变量
	helloCtl.Data["TplVar"] = "hello guys"

	helloCtl.Data["Html"] = "<div>hello beego</div>"
	helloCtl.Data["Pipe"] = "<div>hello beego</div>"
}
